package a.f.d;

import a.c.bb;
import a.c.d;
import a.c.e;
import a.c.k;
import a.c.q;

import java.util.Comparator;

public class g
  extends f
{
  public static boolean p;
  
  protected void a(bb[] paramArrayOfbb, k paramk)
  {
    int j = f.o;
    int i = f.n;
    a(this.l, paramArrayOfbb);
    q localq = new q();
    a.c.x localx = localq.B();
    a(this.l, paramArrayOfbb, localq, localx);
    bb localbb1 = a.a.x.a(localq);
    double[] arrayOfDouble = new double[paramArrayOfbb.length];
    a.c.w localw1 = localbb1.l();
    label197:
    label204:
    do
    {
      if (!localw1.e()) {
        break;
      }
      e locale1 = localw1.d();
      bb localbb2 = (bb)localx.get(locale1);
      double d = 0.0D;
      if (i != 0) {
        return;
      }
      a.c.w localw2 = localbb2.l();
      e locale2;
      do
      {
        do
        {
          if (!localw2.e()) {
            break;
          }
          locale2 = localw2.d();
          d = Math.max(d, arrayOfDouble[paramk.getInt(locale2)] + this.l.s(locale2) / 2.0D);
          localw2.f();
          if (j != 0) {
            break label204;
          }
          if (i != 0) {
            break label197;
          }
        } while (i == 0);
      } while (j != 0);
      localw2 = localbb2.l();
      do
      {
        do
        {
          if (!localw2.e()) {
            break;
          }
          locale2 = localw2.d();
          this.l.a(locale2, d, this.l.n(locale2));
          arrayOfDouble[paramk.getInt(locale2)] = (d + this.l.s(locale2) / 2.0D + this.f);
          localw2.f();
          if (j != 0) {
            break label304;
          }
          if (i != 0) {
            break label302;
          }
        } while (i == 0);
      } while (j != 0);
      localw1.f();
    } while (i == 0);
    label302:
    label304:
    if (j == 0) {
      c(paramArrayOfbb);
    }
  }
  
  void a(q paramq1, bb[] paramArrayOfbb, q paramq2, a.c.x paramx)
  {
    int n = f.o;
    int m = f.n;
    a.c.x localx = paramq1.B();
    Object localObject1 = paramq1.v();
    Object localObject2;
    Object localObject4;
    label179:
    label185:
    label248:
    label250:
    do
    {
      if (!((a.c.w)localObject1).e()) {
        break;
      }
      e locale1 = ((a.c.w)localObject1).d();
      if (m != 0) {
        break label319;
      }
      Object localObject3;
      if (p(locale1))
      {
        if (localx.get(locale1) == null)
        {
          localObject2 = new bb();
          ((bb)localObject2).add(locale1);
          localObject3 = paramq2.i();
          localx.a(locale1, localObject3);
          localObject4 = locale1.i().e();
          if (p((e)localObject4))
          {
            localx.a(localObject4, localObject3);
            ((bb)localObject2).a(localObject4);
          }
          while (n != 0)
          {
            localObject4 = ((e)localObject4).i().e();
            if (n != 0) {
              break label185;
            }
            if (m != 0) {
              break label179;
            }
            if (m == 0) {
              break;
            }
          }
          localObject4 = locale1.h().f();
          if (p((e)localObject4)) {}
          while (n != 0)
          {
            localx.a(localObject4, localObject3);
            ((bb)localObject2).b(localObject4);
            localObject4 = ((e)localObject4).h().f();
            if (n != 0) {
              break label250;
            }
            if (m != 0) {
              break label248;
            }
            if (m == 0) {
              break;
            }
          }
          paramx.a(localObject3, localObject2);
          if (n != 0) {
            continue;
          }
          if (m == 0) {}
        }
      }
      else
      {
        localObject2 = paramq2.i();
        localObject3 = new bb();
        ((bb)localObject3).add(locale1);
        paramx.a(localObject2, localObject3);
        localx.a(locale1, localObject2);
      }
      ((a.c.w)localObject1).f();
    } while (m == 0);
    label319:
    localObject1 = new int[paramq1.k()];
    int i = 0;
    label550:
    label552:
    label587:
    label602:
    do
    {
      if (i >= paramArrayOfbb.length) {
        break;
      }
      localObject2 = paramArrayOfbb[i];
      int j = 0;
      localObject4 = ((bb)localObject2).l();
      if (m != 0) {
        return;
      }
      ((a.c.w)localObject4).h();
      e locale2;
      do
      {
        if (!((a.c.w)localObject4).e()) {
          break;
        }
        localObject5 = ((a.c.w)localObject4).d();
        locale2 = (e)localx.get(localObject5);
        int k = localObject1[locale2.f()];
        if (n != 0) {
          break label602;
        }
        if (m != 0) {
          break label587;
        }
        if (k != 0)
        {
          if (n == 0)
          {
            if (k < j)
            {
              e locale4 = paramq2.i();
              bb localbb1 = (bb)paramx.get(locale2);
              bb localbb2 = new bb();
              paramx.a(locale4, localbb2);
              Object localObject6 = localObject5;
              do
              {
                if (!p((e)localObject6)) {
                  break;
                }
                localx.a(localObject6, locale4);
                localbb2.b(localObject6);
                localbb1.e();
                localObject6 = ((e)localObject6).h().f();
                if (n != 0) {
                  break label552;
                }
                if (m != 0) {
                  break label550;
                }
              } while (m == 0);
            }
            if (n != 0) {}
          }
          else
          {
            j = k;
          }
        }
        else {
          ((a.c.w)localObject4).f();
        }
      } while (m == 0);
      ((a.c.w)localObject4).h();
      if (n == 0) {}
      Object localObject5 = (e)localx.get(((a.c.w)localObject4).d());
      j = 1;
      localObject1[localObject5.f()] = (j++);
      ((a.c.w)localObject4).f();
      do
      {
        do
        {
          if (!((a.c.w)localObject4).e()) {
            break label695;
          }
          locale2 = ((a.c.w)localObject4).d();
          e locale3 = (e)localx.get(locale2);
          if (m != 0) {
            break;
          }
          if (((e)localObject5).a(locale3) == null) {
            paramq2.a((e)localObject5, locale3);
          }
          localObject1[locale3.f()] = (j++);
          localObject5 = locale3;
          ((a.c.w)localObject4).f();
        } while (m == 0);
        i++;
      } while (n != 0);
    } while (m == 0);
    label695:
    if (n == 0) {
      paramq1.a(localx);
    }
  }
  
  private boolean p(e parame)
  {
    int i = f.o;
    if (i == 0)
    {
      if (parame.d() != 1) {
        break label32;
      }
      if (i != 0) {
        break label29;
      }
    }
    label29:
    label32:
    return parame.e() == 1;
  }
  
  void c(bb[] paramArrayOfbb)
  {
    int m = f.o;
    int k = f.n;
    n.a(this, "balanceLayout");
    Comparator local0 = new Comparator()
    {
      public int compare(Object paramAnonymousObject1, Object paramAnonymousObject2)
      {
        e locale1 = ((d)paramAnonymousObject1).f();
        e locale2 = ((d)paramAnonymousObject2).f();
        return g.this.a(locale1, locale2);
      }
    };
    Comparator local1 = new Comparator()
    {
      public int compare(Object paramAnonymousObject1, Object paramAnonymousObject2)
      {
        e locale1 = ((d)paramAnonymousObject1).e();
        e locale2 = ((d)paramAnonymousObject2).e();
        return g.this.a(locale1, locale2);
      }
    };
    a.c.w localw1 = this.l.v();
    do
    {
      do
      {
        if (!localw1.e()) {
          break;
        }
        e locale1 = localw1.d();
        locale1.b(local0);
        locale1.a(local1);
        localw1.f();
      } while (k == 0);
    } while (m != 0);
    int i = 0;
    label154:
    label437:
    label492:
    do
    {
      if (i >= 3) {
        break;
      }
      int j = 0;
      do
      {
        double d1;
        a.c.w localw2;
        e locale2;
        double d2;
        double d3;
        do
        {
          if (j >= paramArrayOfbb.length - 1) {
            break;
          }
          d1 = 1.7976931348623157E+308D;
          localw2 = paramArrayOfbb[j].l();
          n.a(this, "ROW : " + j);
          if (k != 0) {
            break label492;
          }
          localw2.i();
          do
          {
            do
            {
              if (!localw2.e()) {
                break label437;
              }
              locale2 = localw2.d();
              n.a(this, "balancing node " + locale2 + " old centerX = " + this.l.o(locale2).a());
              if (k != 0) {
                break;
              }
              if (!p(locale2))
              {
                d2 = a(locale2, locale2.q()) - this.l.s(locale2) / 2.0D;
                n.a(this, "medianX = " + d2 + "  upperLimitX = " + d1);
                d3 = Math.max(this.l.p(locale2), Math.min(d2, d1 - this.l.s(locale2)));
                n.a(this, "node " + locale2 + " previous posX = " + this.l.p(locale2) + " freshX = " + d3);
                this.l.b(locale2, new a.d.w(d3, this.l.q(locale2)));
              }
              d1 = this.l.p(locale2) - c();
              localw2.g();
            } while (k == 0);
            j++;
          } while (m != 0);
        } while (k == 0);
        if (m == 0) {
          j = paramArrayOfbb.length - 1;
        }
        do
        {
          if (j <= 0) {
            break label656;
          }
          d1 = 1.7976931348623157E+308D;
          localw2 = paramArrayOfbb[j].l();
          if (m != 0) {
            break label154;
          }
          if (k != 0) {
            break;
          }
          localw2.i();
          do
          {
            do
            {
              if (!localw2.e()) {
                break label643;
              }
              locale2 = localw2.d();
              if (k != 0) {
                break;
              }
              if (!p(locale2))
              {
                d2 = a(locale2, locale2.p()) - this.l.s(locale2) / 2.0D;
                d3 = Math.max(this.l.p(locale2), Math.min(d2, d1 - this.l.s(locale2)));
                this.l.b(locale2, new a.d.w(d3, this.l.q(locale2)));
              }
              d1 = this.l.p(locale2) - c();
              localw2.g();
            } while (k == 0);
            j--;
          } while (m != 0);
        } while (k == 0);
        i++;
      } while (m != 0);
    } while (k == 0);
    label643:
    label656:
    return;
  }
  
  private int a(e parame1, e parame2)
  {
    return a(this.l.p(parame1), this.l.p(parame2));
  }
  
  private static int a(double paramDouble1, double paramDouble2)
  {
    int i = f.o;
    if (i == 0) {
      if (paramDouble1 > paramDouble2) {
        return 1;
      }
    }
    if (i == 0) {
      if (paramDouble1 < paramDouble2) {
        return -1;
      }
    }
    return 0;
  }
  
  double a(e parame, a.c.w paramw)
  {
    int k = f.o;
    int j = f.n;
    if (k == 0) {
      if (!paramw.e())
      {
        d = this.l.o(parame).a();
        if ((k == 0) && (j == 0)) {
          return d;
        }
      }
    }
    int i = (paramw.k() - 1) / 2;
    do
    {
      while (j == 0)
      {
        if (i <= 0) {
          break;
        }
        paramw.f();
        i--;
      }
    } while (k != 0);
    double d = this.l.o(paramw.d()).a();
    return d;
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.f.d.g

 * JD-Core Version:    0.7.0.1

 */